<template>
  <div class="search">
    <f-drawer ref="orderDrawer" title="退货补货" width="70%" @submit="handleSubmit" @visibleChange="visibleChange">
      <order-tuibu ref="form1" v-if="drawerVisible"></order-tuibu>
    </f-drawer>
  </div>
</template>
<script>
  import OrderTuibu from './order_tuibu'

  export default {
    name: 'orderTuibuDrawer',
    props: {},
    data() {
      return {
        refs: this.$refs,
        drawerVisible: false,
        isEdit: false,
        title: '',
        stepIndex: 0,
        current: 'form1',
        formData: {},
        forms: [
          'form1'
        ]
      }
    },
    methods: {
      showDrawer(data) {
        this.isEdit = false
        if (data && data.orderId) {
          this.isEdit = true
          this.formData = data
        } else {
          this.formData = {}
        }
        this.refs['orderDrawer'].show()
        this.tabClick('form1')
      },
      handleSubmit(opt) {
        this.refs[this.current].handleSubmit((data) => {
          if (opt == 0) {
            this.$refs.orderDrawer.close()
          } else {
            this.formData = data
            this.tabClick('form2')
          }
        })
      },
      visibleChange(drawerVisible) {
        this.drawerVisible = drawerVisible
        if (drawerVisible == false) {
          //刷新订单列表
          this.$emit('success')
        }
      },
      tabClick(name) {
        this.current = name
        this.$nextTick(() => {
          this.refs[this.current].setData(this.formData)
        })
      }
    },
    computed: {
      drawerTitle: function() {
        return this.title
      }
    },
    created() {
    },
    components: { OrderTuibu }
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
